/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package biofilter.sources;

import biofilter.exceptions.InvalidRecordException;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Daniel Quest
 * @date   Jan 11 2009
 */
public class EMBLRecordsSource extends RecordsFile {


    public EMBLRecordsSource(Object source) throws InvalidRecordException   {
        super( source, "biofilter.records.EMBLRecord");
    }
    
    @Override
    protected String readRecordString() throws InvalidRecordException {
        String record = "";
        try {

            StringBuffer sb = new StringBuffer();
            this.currentRecordString = "";
            while ((currentRecordString = handle.readLine()) != null) {
                if (currentRecordString.startsWith("//")){
                    sb.append(this.currentRecordString);
                    sb.append('\n');
                    return sb.toString();
                }else if(currentRecordString.equalsIgnoreCase("")){
                    ; //do nothing with an empty line
                }else {
                    sb.append(this.currentRecordString);
                    sb.append('\n');
                }
                
                if ( currentRecordString == null)  this.eof = true;

            }
        } catch (IOException ex) {
            Logger.getLogger(EMBLRecordsSource.class.getName()).log(Level.SEVERE, null, ex);
        }
            return record;            
    }
    


}
